package com.in28minutes.login;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@SessionAttributes("name")
public class LoginController {

	@Autowired
	private LoginService loginService = new LoginService();
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String showWelcomePage(ModelMap model) {
		model.put("name", "in28Minutes");
		return "welcome";
	}
	

//	@RequestMapping(value = "/login", method = RequestMethod.GET)
//	public String showLoginPage() {
//		return "login";
//	}
//
//	@RequestMapping(value = "/login", method = RequestMethod.POST)
//	public String handleUserLogin(ModelMap model, @RequestParam String name,
//			@RequestParam String password) {
//
//		if (!loginService.validateUser(name, password)) {
//			model.put("errorMessage", "Invalid Credentials");
//			return "login";
//		}
//
//		model.put("name", name);
//		return "welcome";
//	}
}